package com.codergd.gra.dao;

import com.codergd.gra.bean.Administrator;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface AdministratorDao {
    @Select("select paw from adm where iphone = #{iphone}")
    public String selectAdmin(String iphone);

    @Insert("insert into adm(iphone,paw)"
            + "values (#{iphone},#{paw})")
//    @Results({ @Result(property = "passWord", column = "paw")})
    public int insertAdmin(Administrator administrator);


    @Insert("insert into type(name)"+"values(#{name})")
    public int insertType(String name);

    //根据手机号查找id
    @Select("select id from adm where iphone = #{iphone}")
    public int selectId(String iphone);

    //根据id查状态
    @Select("select state from adm where id = #{id}")
    public int selectState(int id);

    //根据状态查询
    @Select("select * from adm where state = #{state}")
    public List<Administrator> selectByState(int state);

    //根据状态查询
    @Select("select * from adm")
    public List<Administrator> selectAll();

    //根据账号查询
    @Select("select * from adm where iphone = #{iphone}")
    public List<Administrator> selectByIphone(String iphone);

    //两个条件
    @Select("select * from adm where iphone = #{iphone} and state = #{state}")
    public List<Administrator> selectTo(String iphone,int state);

    //修改管理员状态
    @Update("update adm set state = #{state} where id = #{id}")
    public int updateState(int id,int state);



}
